
<template>
  <div class="treeBox">
    <el-tree
      :data="data"
      :show-checkbox="false"
      :auto-expand-parent="false"
      :expand-on-click-node="expandOnClickNode"
      :accordion="false"
      node-key="id"
      :highlight-current="true"
      ref="tree"
      :default-expand-all="isExpandAll"
      :props="defaultProps"
      @node-click="nodeClick"
    ></el-tree>
  </div>
</template>
<script>

export default {
    name: "TreeSingle",
    data() {
        return {
            defaultProps: {
                children: "children",
                label: "name"
            },
        };
    },
    props:["data", "isExpandAll", "expandOnClickNode"],
    watch: {

    },
    created(){
      
    },
    mounted() {
      this.$ge.$on('set-node-by-keys', (node) => {
        this.setCurrentKeys(node);
      })
    },
    methods: {
        nodeClick(data, node, value){
            this.$emit("select-single-back", {data: data, node: node, value: value})
        },
        setCurrentKeys(node) {
          this.$nextTick(() => {
            this.$refs['tree'] && this.$refs['tree'].setCurrentKey(node);
          })
        },
    },
    
   
};
</script>
<style scoped>
/* .treeBox {
  width: 200px;
} */
</style>

